<?php
require_once('config.php');

$username=$_GET['username'];
$password=$_GET['password'];
$telephone=$_GET['telephone'];

$sql="select count(*) from userinfo where username='$username'";

$result=mysqli_query($conn,$sql);

$data=mysqli_fetch_array($result);
$obj=array();
// echo json_encode($data['0']);
if($data['0']>0){
  
    $obj["code"]=0;
    $obj["msg"]='用户名已注册';
    $obj["data"]=false;

 
}else{
   $sql="INSERT into userinfo(username,telephone,password) VALUES ('$username','$telephone','$password')";
   $result=mysqli_query($conn,$sql);

   $cont=mysqli_affected_rows($conn);

   if($cont){
    $obj['code']=1;
    $obj['msg']='注册成功';
    $obj['data']='true';
   }
 
}
echo json_encode($obj);